const db = wx.cloud.database();
const app = getApp();

Page({

  /**
   * 页面的初始数据
   */
  data: {
    inputValue: '',
    inputValueT: '',
    select: false,
    xueLi: '请选择您的年级',
    xueLi2: '是否有考研计划',
    page: 199
  },
  
  bindKeyInput: function (e) {
    var _ = this
    _.setData({
      inputValue: e.detail.value
    })
    console.log(_.data.inputValue)
  },
  bindKeyInputT: function (e) {
    var _ = this
    _.setData({
      inputValueT: e.detail.value
    })
    console.log(_.data.inputValueT)
  },
  onLoad: function (options) {
    var _ = this;
    console.log(options)
    _.setData({
      area: options.area,
      agent: options.agent
    })
    if (options.page) {
      _.setData({
        page: options.page
      })
    }
  },
  bindShowMsg() {
    this.setData({
      select: !this.data.select
    })
  },
  mySelect(e) {
    var name = e.currentTarget.dataset.name
    this.setData({
      xueLi: name,
      select: false
    })
    console.log(this.data.xueLi)
  },
  bindShowMsg2() {
    this.setData({
      select2: !this.data.select2
    })
  },
  mySelect2(e) {
    var name = e.currentTarget.dataset.name
    this.setData({
      xueLi2: name,
      select2: false
    })
    console.log(this.data.xueLi2)
  },
  tj(e) {
    var _ = this;
    console.log(this.data.inputValue)
    console.log(this.data.xueLi)
    wx.request({ //发送请求
      url: "https://zg99.offcn.com/index/biaodan/updateuser/?actid=50256&callback=?",
      data: {
        daji: _.data.xueLi,
        kaoyan: _.data.xueLi2,
        yuanxiao: _.data.inputValue,
        zhuanye: _.data.inputValueT,
        phone: wx.getStorageSync('kxjphone'),
        isagree:true,
      }, //接收参数
      success(res) { //返回
        var jsonStr = res.data;
        jsonStr = jsonStr.replace("(", "");
        jsonStr = jsonStr.replace(")", "");
        if (typeof jsonStr != 'object') {
          jsonStr = jsonStr.replace(/\ufeff/g, ""); //字符串转化JSON对象
          var theJson = JSON.parse(jsonStr);
        };
        console.log(theJson)
        wx.navigateTo({
          url: '../../booklist_st/booklist_st',
        })
      }
    })
    


  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})